/*
 * boards.h 
 *
 * Copyright 2011 Pieter Agten
 *
 * This file is part of Yarf.
 *
 * Yarf is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Yarf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Yarf.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Author : Pieter Agten (pieter.agten@gmail.com)
 * Date : 3 sep 2011
 */

#ifndef BOARDS_H
#define BOARDS_H

#include <avr/io.h>

/****************************************************************************************
* Yarb V1.0 motherboard 
*
*                ATMega644P or ATMega1284P
*
*                        +---\/---+
*            (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
*            (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
*       INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
*        PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
*        PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
*       MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
*       MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
*        SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
*                  RST  9|        |32  AREF
*                  VCC 10|        |31  GND 
*                  GND 11|        |30  AVCC
*                XTAL2 12|        |29  PC7 (D 23)
*                XTAL1 13|        |28  PC6 (D 22)
*       RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
*       TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
*  INT0 RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
*  INT1 TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
*       PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
*       PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
*       PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
*                        +--------+
*
****************************************************************************************/
#if BOARD == 1
#define KNOWN_BOARD 1

#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__) 
#error Oops!  Make sure you are compiling for the correct chip (ATmega644P or ATmega1284p)
#endif

#define LFUSE (FUSE_CKSEL3)
#define HFUSE (FUSE_BOOTSZ0 & FUSE_SPIEN)
#define EFUSE (0xFF)

#define F_CPU 20000000UL     // 20 MHz

#define X_ENABLE_PIN       24
#define X_STEP_PIN         26
#define X_DIR_PIN          25

#define Y_ENABLE_PIN       24
#define Y_STEP_PIN         23
#define Y_DIR_PIN          22

#define Z_ENABLE_PIN       21
#define Z_STEP_PIN         20
#define Z_DIR_PIN          19

#define E_ENABLE_PIN       18
#define E_STEP_PIN         17
#define E_DIR_PIN          16


#define X_MIN_PIN           0
#define Y_MIN_PIN           1
#define Z_MIN_PIN           2

#define X_MAX_PIN          -1 //31
#define Y_MAX_PIN          -1 //30
#define Z_MAX_PIN          -1 //29


//These pins must be connected to OCR0A and OCR0B!
#define HEAT1_PIN           3
#define HEAT2_PIN           4

#define TEMP1_PIN           3 //Analog numbering
#define TEMP2_PIN           4 //Analog numbering

#define NOZZLE_HEATER_INVERTED   0
#define PRINTBED_HEATER_INVERTED 0

#define X_ENABLE_INVERTED   1
#define Y_ENABLE_INVERTED   1
#define Z_ENABLE_INVERTED   1
#define E_ENABLE_INVERTED   1

#define X_STEP_INVERTED     0
#define Y_STEP_INVERTED     0
#define Z_STEP_INVERTED     0
#define E_STEP_INVERTED     0

#define X_MIN_ENDSTOP_INVERTED  0
#define Y_MIN_ENDSTOP_INVERTED  0
#define Z_MIN_ENDSTOP_INVERTED  0

#endif // BOARD == 1




#ifndef KNOWN_BOARD
#error Unknown BOARD value in config.h
#endif

#endif // BOARDS_H
